package com.huawei.mylibrary.dialog;


import ohos.agp.components.Component;
import ohos.agp.components.LayoutScatter;
import ohos.agp.window.dialog.CommonDialog;
import ohos.app.Context;

public class AnimatedDialog<T extends AnimatedDialog> {

    protected Context context;
    protected String title;
    protected String message;

    protected boolean cancelOnTouchOutside;
    protected boolean cancelOnPressBack;
    protected boolean dimBackground;

    protected DialogAnimation.Enter enterAnimation;
    protected DialogAnimation.Exit exitAnimation;

    LayoutScatter layoutScatter;
    CommonDialog dialog;
    Component dialogComponent;

    public AnimatedDialog(Context context){
        this.context = context;
        this.title = "";
        this.message = "";
        this.cancelOnTouchOutside = false;
        this.cancelOnPressBack = false;
        this.dimBackground = true;
        this.enterAnimation = DialogAnimation.Enter.APPEAR;
        this.exitAnimation = DialogAnimation.Exit.DISAPPEAR;
        this.layoutScatter = LayoutScatter.getInstance(context);
        this.dialog = new CommonDialog(context);
//        this.builder = new AlertDialog.Builder(context);
    }

    public T title(String title){
        this.title = title;
        return (T) this;
    }

    public T message(String message){
        this.message = message;
        return (T) this;
    }

    public T title(int resTitle){
        this.title = context.getString(resTitle);
        return (T) this;
    }

    public T message(int resMessage){
        this.message = context.getString(resMessage);
        return (T) this;
    }

    public T cancelOnTouchOutside(boolean cancelOnTouchOutside) {
        this.cancelOnTouchOutside = cancelOnTouchOutside;
        return (T) this;
    }

    public T cancelOnPressBack(boolean cancelOnPressBack){
        this.cancelOnPressBack = cancelOnPressBack;
        return (T) this;
    }

    public T dimBackground(boolean dimBackground){
        this.dimBackground = dimBackground;
        return (T) this;
    }

    public T enterAnimation(DialogAnimation.Enter enterAnimation){
        this.enterAnimation = enterAnimation;
        return (T) this;
    }

    public T exitAnimation(DialogAnimation.Exit exitAnimation){
        this.exitAnimation = exitAnimation;
        return (T) this;
    }


}
